package com.coda.service.impl;

import com.coda.adminVo.user.UserInfoQueryVo;
import com.coda.entity.UserInfo;
import com.coda.mapper.UserMapper;
import com.coda.result.PageResult;
import com.coda.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    /**
     * 条件分页查询用户列表
     * @param current
     * @param size
     * @param userInfoQueryVo
     * @return
     */
    @Override
    public PageResult getPageList(Integer current, Integer size, UserInfoQueryVo userInfoQueryVo) {
        //设置分页参数
        PageHelper.startPage(current,size);
        //查询用户信息
        Page<UserInfo> userInfoPage = userMapper.page(userInfoQueryVo);
        PageResult pageResult = new PageResult(userInfoPage.getTotal(), userInfoPage.getResult());
        return pageResult;
    }

    /**
     * 根据id修改用户状态
     * @param id
     * @param status
     */
    @Override
    public void updateStatus(Long id, Integer status) {
        UserInfo userInfo = new UserInfo();
        userInfo.setId(id);
        userInfo.setStatus(status);
        userMapper.updateStatus(userInfo);
    }

}
